﻿using System;
//using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Configuration;

namespace dbUtils
{
    public class db
    {
        protected static string _constr = ConnectionString;
        protected static string ConnectionString
        {
            get
            {
                if (_constr == null)
                {
                    try
                    {
                        ConnectionStringSettingsCollection connections = ConfigurationManager.ConnectionStrings;
                        if (connections.Count != 0)
                        {
                            foreach (ConnectionStringSettings connection in connections)
                            {
                                _constr = connection.ProviderName;
                                _constr += connection.ConnectionString;
                            }
                        }
                        else
                        {
                            throw new System.Exception("No connection string was defined.");
                        }
                    }
                    catch (System.Exception ex) { throw ex; }
                }
                return db._constr;
            }
        }
    }
}
